class Am extends egret.DisplayObjectContainer {
	private text: any;
	private cuId: any;
	private ract: any;
	private am: any;
	private w: any;
	private h: any; 
	public constructor(w: any, h:any, text: any) {
		super();
		this.text = text;
		// this.ract  = ract;
		this.w = w;
		this.h = h
		this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
	}

	private onAddToStage(): void {
		this.cuId = 1;
		var img = new eui.Image();
		this.am = img;
		img.source = this.text + this.cuId;
		img.width = this.w;
		img.height = this.h;
		this.height = this.h;
		this.width = this.w;
		this.addChild(img);
		this.openAm();
	}
	public openAm(): void {
		this.removeEventListener(egret.Event.ENTER_FRAME, this.enterFrameHandler, this);
		this.addEventListener(egret.Event.ENTER_FRAME, this.enterFrameHandler, this);
	}

	/**打开时逐帧运动*/
	private enterFrameHandler(event: egret.Event): void {
		if (this.cuId < 40) {
			this.cuId += 1;
		} else {
			this.cuId = 1;
		}
		var imgId = (this.cuId + 1) / 2;
		var test = parseInt(imgId.toString());
		this.am.source = this.text + test;
	}

	/**暂停打开时动画*/
	public pauseAm(): void {
		this.removeEventListener(egret.Event.ENTER_FRAME, this.enterFrameHandler, this);
	}

}

